import 'dart:math';

import 'package:x3_base_package/x3_base_package.dart';
import 'package:x3_business_core/business_common_template/models/business_detailed_order_service.dart';
import 'package:x3_business_core/common_components/business_tab_nested_scroll_view.dart';

/// author：william on 2021/3/22 15:33
/// email：362661044@qq.com
///

abstract class BusinessMainOrderConfig {
  /// 入参
  List<BaseHttpRequestModel> get requests;

  /// 明细tab
  List<BusinessTabNestedConfig> get tabs;

  /// 表单provider
  BaseRequestFormProvider get baseRequestFormProvider;

  /// 配置服务
  BusinessDetailedOrderService get serviceConfig;

  /// 设置当前时间
  void setNowDate(String fieldName) {
    if (fieldName != null || fieldName.isNotEmpty) {
      DateTime _now = DateTime.now();
      DateTime _now2 = DateTime(_now.year, _now.month, _now.day);
      String dateTime = BaseTransformUtil.dateTimeAsString(_now2);
      baseRequestFormProvider.dataSource.addAll({fieldName: dateTime});
    }
  }

  /// 自动生成任务名称
  void generateTaskName(String fieldName, String billsName) {
    if (fieldName != null || fieldName.isNotEmpty) {
      String dateTime = BaseTransformUtil.stringToDate(DateTime.now().toIso8601String(), symbol: '');
      String rng = Random().nextInt(1000).toString(); //随机数生成类
      String taskName = BaseStorageUtil.getTokenInfo().userName + billsName + dateTime + rng;
      baseRequestFormProvider.dataSource.addAll({fieldName: taskName});
    }
  }
}
